﻿using System.Collections;

namespace Magellan.Routing
{
    public class RouteMatch
    {
        private readonly bool _success;
        private readonly IRoute _route;
        private readonly string _failReason;
        private readonly RouteValueDictionary _values;

        protected RouteMatch(bool success, IRoute route, IDictionary parameterValues, string failReason)
        {
            _success = success;
            _route = route;
            _failReason = failReason;
            _values = new RouteValueDictionary(parameterValues);
        }

        public static RouteMatch Successful(IRoute route, IDictionary parameterValues)
        {
            return new RouteMatch(true, route, parameterValues, null);
        }

        public static RouteMatch Failure(IRoute route, string reason)
        {
            return new RouteMatch(false, null, null, reason);
        }

        public bool Success
        {
            get { return _success; }
        }

        public IRoute Route
        {
            get { return _route; }
        }

        public RouteValueDictionary Values
        {
            get { return _values; }
        }

        public string FailReason
        {
            get { return _failReason; }
        }
    }
}